package org.iabako.client.ui.page.business.sale;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import org.iabako.client.config.page.PageConfigEnum;
import org.iabako.client.config.page.PageConfigSearchEnum;
import org.iabako.client.config.page.PageEnum;
import org.iabako.client.tools.DefaultSuggestHandler;
import org.iabako.client.ui.form.business.sale.PastInstallmentSearchForm;
import org.iabako.client.ui.layout.widget.datatable.DataTable;
import org.iabako.client.ui.page.AbstractSearchPage;
import org.iabako.shared.iservice.business.ClientServiceAsync;
import org.iabako.shared.iservice.business.PastInstallmentServiceAsync;
import org.iabako.shared.iservice.generic.CRUDServiceAsync;
import org.iabako.shared.iservice.generic.SearchServiceAsync;
import org.iabako.shared.iservice.generic.SuggestServiceAsync;
import org.iabako.shared.querydefinition.dto.QueryDefinitionDTO;

/**
 * Created by jose on 05/09/14.
 */
public class PastInstallmentSearch extends AbstractSearchPage {

    interface MyUiBinder extends UiBinder<HTMLPanel, PastInstallmentSearch> {
    }

    private static final MyUiBinder binder = GWT.create(MyUiBinder.class);

    @UiField
    HTMLPanel pastInstallmentSearchPanel;
    @UiField
    HTMLPanel resultsPanel;

    @Override
    protected SearchServiceAsync getSearchServiceAsync() {
        return PastInstallmentServiceAsync.Util.getInstance();
    }

    @Override
    protected CRUDServiceAsync getCRUDServiceAsync() {
        return null;
    }

    @Override
    protected SuggestServiceAsync getSuggestServiceAsync() {
        return ClientServiceAsync.Util.getInstance();
    }

    @Override
    protected HTMLPanel getResultsPanel() {
        return resultsPanel;
    }

    @Override
    protected HTMLPanel getSearchPanel() {
        return pastInstallmentSearchPanel;
    }

    @Override
    protected HTMLPanel getContentPanel() {
        return binder.createAndBindUi(this);
    }

    @Override
    protected Composite getSearchForm(DataTable dataTable) {
        return new PastInstallmentSearchForm(new DefaultSuggestHandler(getSuggestServiceAsync()), dataTable);
    }

    @Override
    protected PageConfigSearchEnum getSearchPageConfigEnum() {
        return PageConfigSearchEnum.PastInstallmentSearch;
    }

    @Override
    protected PageEnum getModificationPage() {
        return PageEnum.SaleModify;
    }

    @Override
    protected QueryDefinitionDTO getQueryDefinitionDTO() {
        QueryDefinitionDTO queryDefinitionDTO = new QueryDefinitionDTO();
        queryDefinitionDTO.setAscByDefault(false);
        queryDefinitionDTO.setAsc(false);
        return queryDefinitionDTO;
    }
}
